﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using PServiceBus.Core.Interface;
using PServiceBus.Core.Runtime.Configuration;

namespace PServiceBus.Core.Configuration {
    public class FileConfiguration : IConfiguration {
        public FileConfiguration() { }

        public FileConfiguration(string filename) {

        }

        public IServiceBusConfig ServiceBusConfig {
            get { return ConfigurationFactory.GetConfigSection<ServiceBusConfigSection>(); }
        }

        public ILoggerConfig LoggerConfig {
            get { return ConfigurationFactory.GetConfigSection<LoggerConfigSection>(); }
        }

        public IComponentContainerConfig ComponentContainerConfig {
            get { return ConfigurationFactory.GetConfigSection<ComponentContainerConfigSection>(); }
        }

        public IComponentConfig ComponentConfig {
            get { return ConfigurationFactory.GetConfigSection<ComponentConfigSection>(); }
        }

        public IDistributorConfig DistributorConfig {
            get { return ConfigurationFactory.GetConfigSection<DistributorConfigSection>(); }
        }

        public IList<Interface.IMessageStoreConfig> MessageStoreConfigs {
            get {
                return ConfigurationFactory.GetConfigSection<MessageStoreConfigSection>().Stores.Cast<IMessageStoreConfig>().ToList();
            }
        }

        public IList<Interface.ISubscriptionManagerConfig> SubscriptionConfigs {
            get {
                return ConfigurationFactory.GetConfigSection<SubscriptionManagerConfigSection>().Managers.Cast<ISubscriptionManagerConfig>().ToList();
            }
        }

        public Interface.ISecurityConfig SecurityConfig {
            get { return ConfigurationFactory.GetConfigSection<SecurityConfigSection>(); }
        }

        public IList<Interface.IObserverConfig> ObserverConfigs {
            get {
                return ConfigurationFactory.GetConfigSection<ObserverConfigSection>().Observers.Cast<IObserverConfig>().ToList();
            }
        }

        public IList<Interface.ITopicMessageEnricherConfig> TopicEnricherConfigs {
            get {
                return ConfigurationFactory.GetConfigSection<TopicMessageEnricherConfigSection>().Enrichers.Cast<ITopicMessageEnricherConfig>().ToList();
            }
        }

        public IList<Interface.ITopicMessageInspectorConfig> TopicMessageInspectorConfigs {
            get {
                return ConfigurationFactory.GetConfigSection<TopicMessageInspectorConfigSection>().Inspectors.Cast<ITopicMessageInspectorConfig>().ToList();
            }
        }

        public IList<Interface.IWebStreamManagementConfig> WebStreamManagementConfigs {
            get {
                return ConfigurationFactory.GetConfigSection<WebStreamManagementConfigSection>().Streams.Cast<IWebStreamManagementConfig>().ToList();
            }
        }
    }
}
